package com.txtsqlclient.ws;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public abstract class BaseServlet extends HttpServlet {

	private static Log LOGGER = LogFactory.getLog(BaseServlet.class);

	protected void doPost(HttpServletRequest req, HttpServletResponse res) {
		try {
			processRequest(req, res);
		} catch (IOException e) {
			LOGGER.error("Error while sending response", e);
			res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		}
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse res) {
		doPost(req, res);
	}

	protected abstract void processRequest(HttpServletRequest req,
			HttpServletResponse res) throws IOException;
}
